package top.kaoshanji.p1ch08a;

/**
 * 代码清单-p1ch08a-67页c：人类创建工厂
 * @author kaoshanji
 * ^_^
 * create time 2025/3/21 16:34
 */
public class HumanFactory extends AbstractHumanFactory {

    @Override
    public <T extends Human> T createHuman(Class<T> c) {

        // 定义一个生产的人种
        Human human = null;
        try {
            human = (T)Class.forName(c.getName()).newInstance();
        } catch (Exception e) {
            System.out.println("人种生成错误");
        }

        return (T) human;
    }
}
